package com.ztao.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.ztao.service.impl.FileStorageServiceImpl;
import io.minio.errors.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

@RestController
@RequestMapping("/minio")
public class MinioTestController {
    @Resource
    private FileStorageServiceImpl fileStorageService;
    @GetMapping("/uploadHtml")
    public ResponseResult u() throws FileNotFoundException {
        FileInputStream fileInputStream=new FileInputStream("D://02.html");
        try {
            String  url = this.fileStorageService.uploadHtmlFile("02.html", fileInputStream);
            return ResponseResult.okResult(url);
        } catch (Exception e) {
            return ResponseResult.errorResult(666,"minio异常");
        }


    }

}
